home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-15 | 6.2 KB | 348 lines | [TEXT/MWPS] |
- unit LSInterface;
-
-
- interface
-
-
-
- {$IFC UNDEFINED THINK_Pascal}
- uses
- Types, QuickDraw, OSUtils, Fonts, Files, Resources;
- {$ENDC}
-
- const
- kLeft = 1;
- kRight = 2;
- kTop = 3;
- kBottom = 4;
-
- const
- kExtInput = 1; {prmNewClass^.ext = ...}
- kExtOutput = 2;
-
-
- const
- kInputPin = 1;
- kOutputPin = 2;
-
- type
- ClassIDType = record
- name: Str63;
- end;
-
- type
- XBool = integer;
-
- const
- L0 = 0;
- L1 = 1;
- LX = -1; {unknown}
- LZ = -2; {hight impedance}
-
-
- {class messages}
-
- const
- msgNewClass = 1;
- msgDisposeClass = 2;
-
- type
- PrmClassRec = record
- image: PicHandle;
- name: Str255;
- id: ClassIDType;
-
- fileSpec: FSSpec; {reserved}
- ext: integer; {reserved}
- end;
- PrmClassPtr = ^PrmClassRec;
-
- {visual item messages}
-
- const
- msgNewItem = 10;
- msgDisposeItem = 11;
-
- msgSimClick = 12;
- msgDraw = 13;
- msgOptionDialog = 14;
- msgCanOptionDialog = 15;
- msgSetItemParams = 16;
- msgGetItemParams = 17;
-
- type
- PrmItemRec = record
- frame: Rect;
- modifiers: integer;
- canOptionDialog: Boolean;
- paramsStorage: Handle;
- end;
- PrmItemPtr = ^PrmItemRec;
-
- {gate messages}
-
- const
- msgNewGate = 20;
- msgDisposeGate = 21;
-
- msgReset = 22;
- msgSimulation = 23;
- msgGetGateParams = 26;
-
-
- type
- PrmGateRec = record
- paramsStorage: Handle;
- end;
- PrmGatePtr = ^PrmGateRec;
-
- type
- LSEnvRec = record
- setOutputProc: ProcPtr;
- getInputProc: ProcPtr;
- addTimerProc: ProcPtr;
- declarePinProc: ProcPtr;
- forceGateSimProc: ProcPtr;
- invalItemProc: ProcPtr;
- loopProc: ProcPtr;
- addTimer: ProcPtr;
- {and other datas ...}
- end;
- LSEnvPtr = ^LSEnvRec;
-
-
- ClassRefT = ^char;
- ItemRefT = ^integer;
- GateRefT = ^longint;
-
- LSParamPtr = record
- case integer of
- 0: (
- prmClass: PrmClassPtr;
- );
- 1: (
- prmItem: PrmItemPtr;
- );
- 2: (
- prmGate: PrmGatePtr;
- );
- end;
-
- LSBlock = record
- varCode: longint;
- msg: longint;
- prm: LSParamPtr;
- classRef: ClassRefT;
- itemRef: ItemRefT;
- gateRef: GateRefT;
- classDatas: Handle;
- itemDatas: Handle;
- gateDatas: Handle;
- env: LSEnvPtr;
- reserved: longint;
- end;
-
- procedure CallComponentDefProc (blk: LSBlock;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
-
- procedure LSDeclarePin (env: LSEnvPtr;
- classRef: ClassRefT;
- loc: point;
- kind: integer;
- name: Str63);
- procedure LSGetInput (env: LSEnvPtr;
- gateRef: GateRefT;
- pin: integer;
- var value: XBool);
- procedure LSSetOutput (env: LSEnvPtr;
- gateRef: GateRefT;
- pin: integer;
- value: XBool);
- procedure LSForceGateSim (env: LSEnvPtr;
- gateRef: GateRefT);
- procedure LSInvalItem (env: LSEnvPtr;
- itemRef: ItemRefT);
- procedure LSAddTimer (env: LSEnvPtr;
- gateRef: GateRefT;
- date: longint);
- procedure LSLoop (env: LSEnvPtr;
- itemRef: ItemRefT);
-
- function Pnt (h, v: integer): Point;
-
- function CompareClassID (id1, id2: ClassIDType): boolean;
- procedure SetClassID (var id: ClassIDType;
- s: str63);
-
- function _AND (a, b: XBool): XBool;
- function _OR (a, b: XBool): XBool;
- function _NOT (a: XBool): XBool;
- function RisingFront (oldv, newv: XBool): boolean;
-
-
- implementation
-
- function CompareClassID (id1, id2: ClassIDType): boolean;
- begin
- CompareClassID := (id1.name = id2.name);
- end;
-
- procedure SetClassID (var id: ClassIDType;
- s: str63);
- begin
- id.name := s;
- end;
-
- function Pnt (h, v: integer): Point;
- var
- p: Point;
- begin
- p.h := h;
- p.v := v;
- Pnt := p;
- end;
-
- function _AND (a, b: XBool): XBool;
- var
- result: XBool;
- begin
- if (a = L1) & (b = L1) then
- result := L1
- else if (a = L0) | (b = L0) then
- result := L0
- else
- result := LX;
- _AND := result;
- end;
-
- function _OR (a, b: XBool): XBool;
- var
- result: XBool;
- begin
- if (a = L1) | (b = L1) then
- result := L1
- else if (a = L0) & (b = L0) then
- result := L0
- else
- result := LX;
- _OR := result;
- end;
-
- function _NOT (a: XBool): XBool;
- var
- result: XBool;
- begin
- if a = L0 then
- result := L1
- else if a = L1 then
- result := L0
- else
- result := LX;
- _NOT := result;
- end;
-
- function RisingFront (oldv, newv: XBool): boolean;
- begin
- RisingFront := ((newv = L1) & (oldv = L0));
- end;
-
- procedure Call_DeclarePin (classRef: ClassRefT;
- loc: point;
- kind: integer;
- name: Str63;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSDeclarePin (env: LSEnvPtr;
- classRef: ClassRefT;
- loc: point;
- kind: integer;
- name: Str63);
- begin
- Call_DeclarePin(classRef, loc, kind, name, env^.declarePinProc);
- end;
-
- procedure Call_SetOutput (gateRef: GateRefT;
- pin: integer;
- value: XBool;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSSetOutput (env: LSEnvPtr;
- gateRef: GateRefT;
- pin: integer;
- value: XBool);
- begin
- Call_SetOutput(gateRef, pin, value, env^.setOutputProc);
- end;
-
- procedure Call_GetInput (gateRef: GateRefT;
- pin: integer;
- var value: XBool;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSGetInput (env: LSEnvPtr;
- gateRef: GateRefT;
- pin: integer;
- var value: XBool);
- begin
- Call_GetInput(gateRef, pin, value, env^.getInputProc);
- end;
-
-
- procedure Call_ForceGateSim (gateRef: GateRefT;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSForceGateSim (env: LSEnvPtr;
- gateRef: GateRefT);
- begin
- Call_ForceGateSim(gateRef, env^.ForceGateSimProc);
- end;
-
-
- procedure Call_InvalItem (itemRef: ItemRefT;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSInvalItem (env: LSEnvPtr;
- itemRef: ItemRefT);
- begin
- Call_InvalItem(itemRef, env^.InvalItemProc);
- end;
-
- procedure Call_Loop (itemRef: ItemRefT;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSLoop (env: LSEnvPtr;
- itemRef: ItemRefT);
- begin
- Call_Loop(itemRef, env^.loopProc);
- end;
-
-
- procedure Call_AddTimer (gateRef: GateRefT;
- date: longint;
- proc: ProcPtr);
- inline
- $205F, $4E90;
-
- procedure LSAddTimer (env: LSEnvPtr;
- gateRef: GateRefT;
- date: longint);
- begin
- Call_AddTimer(gateRef, date, env^.addTimerProc);
- end;
-
- end.